using System;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace Voodoo.Meta.RVModules
{
	public class ChestHidder : MonoBehaviour
	{
		public Animator animator;

		public TextMeshProUGUI text;

		public Image image;

		private const string _open = "Open";

		private const float _delayItemAnimator = 0.25f;

		public void Set(RewardInfo parameters)
		{
			if (image != null)
			{
				image.sprite = parameters.sprite;
				image.color = Color.white;
			}
			if (text != null)
			{
				text.text = parameters.amount.ToString();
			}
		}

		public void Open()
		{
			animator.SetTrigger("Open");
		}

		public void OnOpened()
		{
			WaitBeforeItemAnimator();
		}

		private async void WaitBeforeItemAnimator()
		{
			await Task.Delay(TimeSpan.FromSeconds(0.25));
		}
	}
}
